package com.soryin.service.impl;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;

import com.soryin.dao.OpenPlatformDao;
import com.soryin.entity.OpenPlatform;
import com.soryin.service.OpenPlatformService;

/**
 * 开放平台账号 Service
 * @author Hello_海生
 * @date 2014年3月21日
 */
public class OpenPlatformServiceImpl implements OpenPlatformService {
	
	@Resource
	private OpenPlatformDao openPlatformDao;

	
	@Override
	public Serializable save(OpenPlatform o) {
		if(!o.getSid().equals("") && !o.getType().equals("")){
			if(openPlatformDao.selectOpenPlatformByTypeAndSid(o.getType(),o.getSid())!=null){
				return openPlatformDao.save(o);
			}
		}
		return 0;
	}

	@Override
	public void delete(int id) {
		openPlatformDao.delete(id);
	}

	@Override
	public OpenPlatform selectOpenPlatformByTypeAndSid(String type,String sid) {
		return openPlatformDao.selectOpenPlatformByTypeAndSid(type,sid);
	}

	@Override
	public List<OpenPlatform> selectOpenPlatformByUserId(int id) {
		// TODO Auto-generated method stub
		return openPlatformDao.selectOpenPlatformByUserId(id);
	}

	@Override
	public void update(OpenPlatform o) {
		if(o.getId()!=0 && !o.getSid().equals("") && !o.getType().equals("") && o.getUserId().getId()!=0){
			openPlatformDao.update(o);
		}
	}


}
